﻿using System;
using System.Collections.Generic;
using DapperExtensions.Mapper;
using Newtonsoft.Json;

namespace ZilLion.Service.ZilLionOss.Domain.Entitys
{
    public class OssRouteJsonEntity
    {
        public string RouteJson { get; set; }
        public DateTime UpdateTime { get; set; }
    }

    public class OssRouteJsonEntityMapper : ClassMapper<OssRouteJsonEntity>
    {
        public OssRouteJsonEntityMapper()
        {
            Table("oss_all_route");
            Map(f => f.RouteJson).Column("routejson");
            Map(f => f.UpdateTime).Column("updatetime");
        }
    }

    public class OssRouteInfoEntity
    {
        /// <summary>
        ///     路由完整路径
        /// </summary>
        [JsonProperty("path")]
        public string Path { get; set; }

        /// <summary>
        ///     父节点路径
        /// </summary>
        [JsonProperty("parentpath")]
        public string ParentPath { get; set; } = string.Empty;

        /// <summary>
        ///     是否有子路径
        /// </summary>
        [JsonProperty("haschild")]
        public bool? Haschild { get; set; }

        /// <summary>
        ///     跳转路径
        /// </summary>
        [JsonProperty("redirect")]
        public string Redirect { get; set; }

        /// <summary>
        ///     路由名称
        /// </summary>
        [JsonProperty("name")]
        public string Name { get; set; }

        [JsonProperty("icon")]
        public string Icon { get; set; }

        [JsonProperty("componentpath")]
        public string Componentpath { get; set; }

        [JsonProperty("children")]
        public List<OssRouteInfoEntity> Children { get; set; }

        [JsonProperty("hidden")]
        public bool? Hidden { get; set; }

        [JsonProperty("isconstant")]
        public bool? IsConstant { get; set; }

        [JsonProperty("nodropdown")]
        public bool? Nodropdown { get; set; }

        [JsonProperty("module")]
        public string Module { get; set; }
        
        [JsonProperty("isadmin")]
        public bool? IsAdmin { get; set; }
        [JsonProperty("issystem")]
        public bool? IsSystem { get; set; }
    }


    public class OssRouteInfoEntityMapper : ClassMapper<OssRouteInfoEntity>
    {
        public OssRouteInfoEntityMapper()
        {
            Table("oss_route_info");
            Map(f => f.Path).Column("routepath").Key(KeyType.Assigned);
            Map(f => f.ParentPath).Column("routeparentpath");
            Map(f => f.Haschild).Column("routehaschild");
            Map(f => f.Redirect).Column("routeredirect");
            Map(f => f.Nodropdown).Column("routenodropdown");
            Map(f => f.Name).Column("routename");
            Map(f => f.Icon).Column("routeicon");
            Map(f => f.Hidden).Column("routehidden");
            Map(f => f.IsConstant).Column("routeisconstant");
            Map(f => f.Componentpath).Column("routecomponentpath");
            Map(f => f.IsAdmin).Column("routeisadmin");
            Map(f => f.IsSystem).Column("routeissystem");
            Map(f => f.Module).Column("routemodule");
        }
    }
}